package com;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/s3")
public class MyServlet3 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.重定向
//        resp.sendRedirect("/s4");
        //2.请求转发
        RequestDispatcher h4 = req.getRequestDispatcher("s4");
        h4.forward(req,resp);
        //重定向可以定义到任何地址，请求转发只能内部转换地址

        req.setAttribute("aa","Avalue");
    }
}
